<?php
require ROOT . 'paginas/poll/class.php';

$poll = new Poll;

if(User::getID() != null)
{
	if(isset($_POST['poll_antwoord']) && !$poll->hasUserVoted(User::getId()))
	{
		$poll->attemptVote(User::getId(), $_POST['poll_antwoord']);
	}

	if($poll->hasUserVoted(User::getId()))
	{
		$poll->showPollResults();
	}
	else
	{
		$poll->showLatestPoll();
	}
}
else
{
	$poll->showLatestPoll(true);
}